require("../../requests/request.js"), getApp();

Page({
    data: {
        DealerName: "1",
        DealerSaleAddr: "2",
        DealerTel: "3",
        Is4S: "",
        DealerBizModeName: "4",
        BaiduMapLat: 0,
        BaiduMapLng: 0,
        markers: [],
        controls: [ {
            id: 1,
            iconPath: "/resources/location.png",
            position: {
                left: 0,
                top: 250,
                width: 50,
                height: 50
            },
            clickable: !0
        } ],
        circles: []
    },
    onLoad: function(a) {
        var e = this;
        wx.getSystemInfo({
            success: function(a) {
                e.setData({
                    winHeight: a.windowHeight
                });
            }
        }), e.data.BaiduMapLat = parseFloat(a.BaiduMapLat), e.data.BaiduMapLng = parseFloat(a.BaiduMapLng), 
        e.setData({
            DealerName: a.DealerName,
            DealerSaleAddr: a.DealerSaleAddr,
            DealerTel: a.DealerTel,
            Is4S: a.Is4S,
            DealerBizModeName: a.DealerBizModeName,
            BaiduMapLat: e.data.BaiduMapLat,
            BaiduMapLng: e.data.BaiduMapLng,
            markers: [ {
                id: 0,
                latitude: e.data.BaiduMapLat,
                longitude: e.data.BaiduMapLng,
                width: 50,
                height: 50
            } ],
            circles: [ {
                id: 0,
                latitude: e.data.BaiduMapLat,
                longitude: e.data.BaiduMapLng,
                width: 50,
                height: 50,
                radius: 5,
                color: "#000000FF",
                fillColor: "#000000AA",
                strokeWidth: 2
            } ]
        }), console.log(e.data);
    },
    onReady: function(a) {
        var e = this;
        wx.setNavigationBarTitle({
            title: e.data.DealerName
        }), this.mapCtx = wx.createMapContext("myMap");
    },
    getCenterLocation: function() {
        var a = this;
        this.mapCtx.getCenterLocation({
            success: function(e) {
                e.latitude, e.longitude;
                console.log(a.data.BaiduMapLng), console.log(a.data.BaiduMapLat);
            }
        });
    },
    openLocation: function() {
        var a = this;
        wx.openLocation({
            latitude: a.data.BaiduMapLat,
            longitude: a.data.BaiduMapLng,
            scale: 28,
            name: a.data.DealerName,
            address: a.data.DealerSaleAddr
        });
    },
    moveToLocation: function() {
        this.mapCtx.moveToLocation();
    },
    telDealer: function(a) {
        console.log("正在拨打电话" + a.currentTarget.dataset.tel), wx.showModal({
            title: "拨打电话",
            content: "电话号码：" + a.currentTarget.dataset.tel,
            success: function(e) {
                e.confirm && wx.makePhoneCall({
                    phoneNumber: a.currentTarget.dataset.tel
                });
            }
        });
    },
    goHere: function() {},
    regionchange: function(a) {
        console.log(a.type);
    },
    markertap: function(a) {
        console.log(a.markerId);
    },
    controltap: function(a) {
        console.log(a.controlId);
    }
});